/*
 * Niiuzu
 * Copyright (C) 2011  Thierry Nowak
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.niiuzu.client.screen.application.home;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.mvp4g.client.annotation.Presenter;
import com.mvp4g.client.presenter.LazyPresenter;
import com.niiuzu.client.eventbus.ApplicationEventBus;

/**
 * Presenter de la page d'accueil.
 */
@Presenter(view = HomeViewImpl.class)
public class HomePresenter extends LazyPresenter<HomeView, ApplicationEventBus> {

	private ClickHandler logInClickHandler;
	private ClickHandler signUpClickHandler;

	@Override
	public void bindView() {
		super.bindView();

		logInClickHandler = new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				eventBus.logInFormWanted();
			}
		};
		view.getLogInHasClickHandlers().addClickHandler(logInClickHandler);

		signUpClickHandler = new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				eventBus.signUpFormWanted();
			}
		};
		view.getSignUpHasClickHandlers().addClickHandler(signUpClickHandler);
	}

	/**
	 * Réception d'une demande de chargement de la page d'accueil.
	 * 
	 * @see ApplicationEventBus#homeLoadStarting()
	 */
	public void onHomeLoadStarting() {
		eventBus.homeLoaded(view);
	}

	/**
	 * Comportement d'un clic sur le bouton de connexion de l'utilisateur.
	 */
	ClickHandler getLogInClickHandler() {
		return logInClickHandler;
	}

	/**
	 * Comportement d'un clic sur le bouton de création de compte.
	 */
	ClickHandler getSignUpClickHandler() {
		return signUpClickHandler;
	}
}
